#include<bits/stdc++.h>
#define ll long long
#define Max(a,b,c)  max(a,max(b,c))
#define inf 2100000000
#define fa(i,n,k) for(register int i=k;i<=n;i++)

using namespace std;
int n,a[200005];
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	cin>>n;
	int last=-1,k=n;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(last!=x)
			last=x,cout<<i<<' ',k--,a[i]=-1;
		else a[i]=x;
	}
	cout<<endl;
	while(k!=0){
		last=-1;
		int f=0;
		for(int i=1;i<=n;i++){
			if(a[i]==-1)continue;
			else if(last!=a[i])last=a[i],a[i]=-1,cout<<i<<' ',k--,f=1;
//			else continue;
		}
		if(f)cout<<endl;
	}
	return 0;
}

